package cn.fxw.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.fxw.mapper.UserMapper;
import cn.fxw.pojo.User;
import cn.fxw.pojo.UserExample;
import cn.fxw.pojo.UserExample.Criteria;
import cn.fxw.service.IUserService;

@Service
public class UserServiceImpl implements IUserService{

	@Autowired
	private UserMapper userMapper;

	public User getUserById(int userId) {

		UserExample example = new UserExample();
		Criteria criteria = example.createCriteria();
		criteria.andIdEqualTo(userId);
		List<User> list = userMapper.selectByExample(example);
		if (list != null && list.size() > 0) {
			User user = list.get(0);
			return user;
		}
		return null;

		/**
		 * User user = userMapper.selectByPrimaryKey(userId);
		 * return user;
		 */

	}

}
